const express = require('express');
//创建路由对象
const router = express.Router();

// 导入路由处理函数对应的模块
const { reguser, login } = require('../handler/reg_log');
const { addAnswer } = require('../handler/answer');
const { getPaperById } = require('../handler/paper');

//导入验证数据的中间件
const expressJoi = require('@escook/express-joi');
//导入需要的验证规则对象
const { reg_login_schema } = require('../schema/user');

//注册新用户
router.post('/reguser', expressJoi(reg_login_schema), reguser);
//用户登录
router.post('/login', expressJoi(reg_login_schema), login);

// 根据id获取单个问卷
router.get('/paper/:id', getPaperById);
// 添加答卷
router.post('/submit', addAnswer);

module.exports = router;
